using MediatR;
using SumerCoreDevOps.Application.Workflows.Commands;
using SumerCoreDevOps.Infrastructure.Workflow;

namespace SumerCoreDevOps.Application.Workflows.Handlers;

/// <summary>
/// 启用工作流命令处理器
/// </summary>
public class EnableWorkflowCommandHandler : IRequestHandler<EnableWorkflowCommand, Unit>
{
    private readonly WorkflowDefinitionManager _definitionManager;

    public EnableWorkflowCommandHandler(WorkflowDefinitionManager definitionManager)
    {
        _definitionManager = definitionManager;
    }

    public async Task<Unit> Handle(EnableWorkflowCommand request, CancellationToken cancellationToken)
    {
        await _definitionManager.EnableWorkflowAsync(request.Id);
        return Unit.Value;
    }
}
